package org.zs.miracle.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.AllArgsConstructor;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.zs.miracle.common.base.dto.BaseManyLongIdDTO;
import org.zs.miracle.service.notice.INoticeService;
import org.zs.miracle.service.notice.model.dto.AddNoticeDTO;
import org.zs.miracle.service.notice.model.dto.EditNoticeDTO;
import org.zs.miracle.service.notice.model.dto.NoticeQueryPageDTO;
import org.zs.miracle.service.notice.model.vo.NoticeVO;

/**
 * 通知公告表Controller层,接受处理请求
 */
@Tag(name = "通知公告接口")
@RestController
@RequestMapping("/notice")
@AllArgsConstructor
public class NoticeController {
  
  @Resource
  INoticeService noticeService;
  
  @Operation(summary = "分页查询", description = "分页查询通知公告接口}")
  @GetMapping(value = "/pageQueryList", produces = MediaType.APPLICATION_JSON_VALUE)
  @ApiResponse(responseCode = "200", description = "OK")
  
  public Page<NoticeVO> pageQueryList(NoticeQueryPageDTO inputDTO) {
    return noticeService.pageQueryList(inputDTO);
  }
  
  @Operation(summary = "添加通知公告", description = "添加通知公告接口")
  @ApiResponse(responseCode = "200", description = "OK")
  @PostMapping(value = "/addNotice", produces = MediaType.APPLICATION_JSON_VALUE)
  public Boolean addNotice(@RequestBody @Validated AddNoticeDTO inputDTO) {
    return noticeService.addNotice(inputDTO);
  }
  
  @Operation(summary = "删除通知公告", description = "根据id删除接口")
  @ApiResponse(responseCode = "200", description = "OK")
  @DeleteMapping(value = "/delNotice", produces = MediaType.APPLICATION_JSON_VALUE)
  public Boolean delNotice(@RequestBody @Validated BaseManyLongIdDTO inputDTO) {
    return noticeService.delNotice(inputDTO);
  }
  
  @Operation(summary = "编辑通知公告", description = "编辑通知公告接口")
  @ApiResponse(responseCode = "200", description = "OK")
  @PatchMapping(value = "/editNotice", produces = MediaType.APPLICATION_JSON_VALUE)
  public Boolean addNotice(@RequestBody @Validated EditNoticeDTO inputDTO) {
    return noticeService.editNotice(inputDTO);
  }
}